package com.example.singleton;

import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;

/**
 * @Description : 单例模式: 饿汉
 * @Author : Bruce Lee
 * @CreateTime : 2025/3/13
 */

@Slf4j
public class hungerSingleton {

    private HashMap<String, Integer> map = new HashMap<>();

    private static hungerSingleton mySingleton = new hungerSingleton();

    private hungerSingleton() {
    }

    public static hungerSingleton getSingleton(){
        return mySingleton;
    }

    public void add(String key, Integer value){
        map.put(key, value);
        log.info("add key:{} value:{}", key, value);
    }

    public void remove(String key){
        map.remove(key);
        log.info("remove key:{}", key);
    }

    public HashMap<String, Integer> getMap(){
        return map;
    }

}
